
<!-- CEK LAGI--->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Report:: Medical</title>
<link rel="stylesheet" type="text/css" href="../style/style.css" />
<style type="text/css">
	.BT{
		border-bottom: solid 1px #000000;
		border-top: solid 1px #000000;
	}
	.LBT{
		border-left: solid 1px #000000;
		border-bottom: solid 1px #000000;
		border-top: solid 1px #000000;
	}
	.RLBT{
		border-left: solid 1px #000000;
		border-right: solid 1px #000000;
		border-bottom: solid 1px #000000;
		border-top: solid 1px #000000;
	}
	.LB{
		border-left: solid 1px #000000;
		border-bottom: solid 1px #000000;
	}
	.RB{
		border-right: solid 1px #000000;
		border-bottom: solid 1px #000000;
	}
	.LRB{
		border-right: solid 1px #000000;
		border-left: solid 1px #000000;
		border-bottom: solid 1px #000000;
	}
</style>
</head>

<body>
<?
	$nik 	= $HTTP_GET_VARS['nik'];
	$no_res	= $HTTP_GET_VARS['no_res'];
	$periode= $HTTP_GET_VARS['periode'];
	include("../lib/config.php");
	
	$sql	= mssql_query("SELECT *, CONVERT(CHAR(12), tanggal, 103) TglRestitusi FROM MedicalRestitusiDetail A, Karyawan B WHERE A.NIK=B.NIK AND nomor='$no_res'",$conn);
	$row	= mssql_fetch_array($sql);
?>
<table width="100%">
 <tr>
  <td align="center"><h2><b>RESTITUSI BIAYA PENGOBATAN</b></h2></td>
 </tr>
 <tr>
  <td><hr noshade="noshade" width="80%" size="-2" /></td>
 </tr>
 <tr>
  <td>
   <table width="70%" align="center" border="0">
    <tr>
     <td width="100">No. Restitusi</td>
     <td>: <?=$row[nomor]?></td>
     <td>&nbsp;</td>
     <td width="100">Tgl. Restitusi</td>
     <td>: <?=$row[TglRestitusi]?></td>
    </tr>   
    <tr>
     <td>Nama</td>
     <td>: <?=$row[Nama]?></td>
     <td>&nbsp;</td>
     <td>NIK</td>
     <td>: <?=$row[NIK]?></td>
    </tr>
   <?
   	// get karir paling terakhir
	$sqlgkl = mssql_query("SELECT kode_so1, kode_so2 FROM VKarirPTSI WHERE NIK='$nik' ORDER BY seqno DESC",$conn);
	$rowgkl = mssql_fetch_array($sqlgkl);
	// kode so
	if(empty($rowgkl[kode_so1])){
		$kodeso = $rowgkl[kode_so2];
	}
	else{
		$kodeso = $rowgkl[kode_so1];
	}
	
	// 000000000000
	// 123456789012
	// 012345678901
	// 1111111
	if(trim($kodeso)== ""){
	}
	else{
		$s1 = mssql_query("SELECT * FROM VLevelCabang WHERE substring(kode_so,1,7)='".substr($kodeso,0,7)."'", $conn);
		if(mssql_num_rows($s1) > 0){
			$r1 = mssql_fetch_array($s1);
			//mssql_free_result($s1x);
			//echo"$r1[uraian]";
			$divisi = $r1[uraian];
			// get cabang
			//$sgc = mssql_query("SELECT * FROM VLevelBagian WHERE substring(kode_so,1,10)='".substr($kodeso,0,10)."'",$conn);
			//$rgc = mssql_fetch_array($sgc);
			//$bagian = $rgc[uraian];
		}
	}	

	//$sql = mssql_query("SELECT * FROM VLevelCabang WHERE kode_so='$divisi'",$conn);
	//$row = mssql_fetch_array($sql);
   ?>
    <tr>
     <td>Divisi/Biro</td>
     <td>: <?=$divisi?></td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
    </tr>
   </table>
  </td>
 </tr>
 <tr>
  <td><hr noshade="noshade" width="80%" size="-2" /></td>
 </tr>
 <tr>
  <td>
   <table align="center" width="80%" border="0" cellpadding="2" cellspacing="0">
    <tr>
     <td rowspan="2" align="center" class="LBT">No.</td>
     <td rowspan="2" align="center" class="LBT">Tanggal<br />Kwitansi</td>
     <td rowspan="2" align="center" class="LBT">Nama<br />Tertanggung</td>
     <td rowspan="2" align="center" class="LBT">Status <br />Keluarga</td>
     <td rowspan="2" align="center" class="LBT">Nama Apotik/RS/<br />Apotik/Optik</td>
     <td rowspan="2" align="center" class="LBT">Kode Mata<br />Anggaran</td>
     <td colspan="2" align="center" class="RLBT">Jumlah (Rp.)</td>
    </tr>
    <tr>
     <td align="center" class="LB" width="100">Diajukan</td>
     <td align="center" class="LRB" width="100">Disetujui</td>
    </tr>
    <?
    	$sql1 = mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY nomor) as No, *, CONVERT(CHAR(12), tanggal, 103) tgl_kwitansi FROM MedicalRestitusiDetail WHERE nomor='$row[nomor]'",$conn);
		//;
		while($row1 = mssql_fetch_array($sql1)){
		echo'
		<tr>
		 <td class="LB" align=right>'.$row1[No].'</td>
		 <td class="LB" align=center>'.$row1[tgl_kwitansi].'</td>
		 <td class="LB">'.$row1[nama_tertanggung].'</td>
		 <td class="LB">';
		echo"$row1[status_kel]";
		echo'</td>
		 <td class="LB">'.$row1[nama_dokter].'</td>
		 <td class="LB" align=center>';
		if(empty($row1[mata_anggaran])){
			echo"&nbsp;";
		}
		else{
			echo"$row1[mata_anggaran]";
		}
		echo'</td>
		 <td class="LB" align=right>Rp.'.number_format($row1[jml_diajukan]).'</td>
		 <td class="LRB" align=right>Rp.'.number_format($row1[jml_disetujui]).'</td>
		</tr>';
		}
		
		// get jumlah yang disetujui
		$sJml 	= mssql_query("SELECT sum(jml_diajukan) jumlah_ajukan, sum(jml_disetujui) jumlah_setuju FROM MedicalRestitusiDetail WHERE nomor='$row[nomor]'",$conn);
		$rJml	= mssql_fetch_array($sJml);
	?>
    <tr>
     <td align="right" colspan="6" class="LB"><b>Jumlah</b></td>
     <td class="LB" align="right"><b>Rp. <?=number_format($rJml[jumlah_ajukan])?></b></td>
     <td class="LRB" align="right"><b>Rp. <?=number_format($rJml[jumlah_setuju])?></b></td>     
    </tr>
    <tr>
     <td colspan="8">&nbsp;</td>
    </tr>
    <tr>
     <td colspan="5"><b>KODE MATA ANGGARAN:</b>
     <table>
     <?
     	$sMA = mssql_query("select * from MedicalMataAnggaran",$conn);
		while($rMA = mssql_fetch_array($sMA)){
			echo"
			 <tr>
			  <Td>$rMA[mata_anggaran]</td>
			  <Td>$rMA[uraian]</td>
			 </tr>
			";
		}
	 ?>
      <tr>
       <td></td>
      </tr>
     </table>
     </td>
     <td valign="top" colspan="2">Diperiksa Oleh</td>
     <td valign="top">Diajukan Oleh</td>     
    </tr>
    <?
    	$sql4 = mssql_query("select * from MedicalRestitusi where nomor='$row[nomor]'",$conn);
		$row4 = mssql_fetch_array($sql4);
	?>
    <tr>
     <td colspan="5">&nbsp;</td>
     <td valign="bottom" colspan="2"><u><?=$row[DiperiksaBy]?></u></td>
     <td valign="bottom"><u><?=$row[Nama]?></u></td>
    </tr>
    <tr>
     <td colspan="5">&nbsp;</td>
     <td valign="bottom" colspan="2">NIK:</td>
     <td valign="bottom">NIK: <?=$row[NIK]?></td>
    </tr>
    <tR>
     <td colspan="3"><b>CATATAN VERIFIKASI</b></td>
    </tR>
    <tr>
     <td colspan="3" valign="top">
      <table width="200" cellpadding="4" cellspacing="0">
       <tR>
        <td>RAWAT INAP **)</td>
       </tR>
       <tr>
        <td class="LBT" style="border-right:solid 1px #000000;">BEBAN PERUSAHAAN<br />
        Rp. <?=number_format($row4[RI_Prsh])?></td>
       </tr>
       <tr>
        <td class="LRB">BEBAN PEGAWAI<br />
        Rp. <?=number_format($row4[RI_Kar])?></td>
       </tr>
      </table>
     </td>
    <?
	 	// ambil data plafon
		$sPlaf = mssql_query("SELECT PlafonRawatJalan FROM MedicalSetupAwal WHERE Periode='$periode' AND NIK='$nik'",$conn);
		$rPlaf = mssql_fetch_array($sPlaf);
		// ambil data plafon yang terpakai rawat jalan
		$sRJ = mssql_query("SELECT SUM(jml_disetujui) tot_setuju FROM MedicalRestitusiDetail WHERE Periode='$periode' AND NIK='$nik' AND mata_anggaran NOT IN ('811104') AND status='A'");
		$rRJ = mssql_fetch_array($sRJ);
	?>
     <td colspan="5">
      <table width="200" cellpadding="4" cellspacing="0">
       <tR>
        <td>PLAFON RAWAT JALAN</td>
       </tR>
       <tr>
        <td class="LBT" style="border-right:solid 1px #000000;">SALDO AWAL PLAFON<br />
        Rp. <?=number_format($rPlaf[0])?></td>
       </tr>
       <tr>
        <td class="LRB">JUMLAH PLAFON YANG DIGUNAKAN<br />
        Rp. <?=number_format($rRJ[tot_setuju])?></td>
       </tr>
       <tr>
        <td class="LRB">SALDO AKHIR PLAFON<br />
        Rp. <?=number_format($rPlaf[0]-$rRJ[tot_setuju])?></td>
       </tr>
      </table>
     </td>
    </tr>
   </table>
  </td>
 </tr>
 <tr>
  <td><hr noshade="noshade" size="-2" width="80%" /></td>
 </tr>
 <tr>
  <td>
   <table width="80%" align="center"> 
    <tr>
     <td>
     <i>Distribusi:</i><br />
     Lembar Ke-1 : Seksi Verifikasi &amp; Pajak - BKA / Bagian Adum - Cabang<br />
     Lembar Ke-2 : Arsip<br /><br />
     <i>Keterangan</i><br />
     *) Coret yang tidak perlu<br />
     **) Khusus rawat inap yang menggunakan surat jaminan
     </td>
    </tr>
   </table>
  </td>
 </tr>
</table>
</body>
</html>

